// Copyright 2011 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package dfa.axis.v1_16;

import com.google.api.ads.dfa.lib.client.DfaSession;
import com.google.api.ads.dfa.lib.factory.DfaServices;
import com.google.api.ads.dfa.axis.v1_16.ContentCategory;
import com.google.api.ads.dfa.axis.v1_16.ContentCategoryRemote;
import com.google.api.ads.dfa.axis.v1_16.ContentCategorySaveResult;

/**
 * This example creates a content category with the given name and description.
 *
 * Credentials and properties in {@code fromFile()} are pulled from the
 * "ads.properties" file. See README for more info.
 *
 * Tags: contentcategory.saveContentCategory
 *
 * @author Joseph DiLallo
 */
public class CreateContentCategory {

  public static void main(String[] args) throws Exception {
    String contentCategoryName = "INSERT_CONTENT_CATEGORY_NAME_HERE";
    String contentCategoryDescription = "INSERT_CONTENT_CATEGORY_DESCRIPTION_HERE";

    // Initialize your session.
    DfaSession session = new DfaSession.Builder().fromFile().build();

    // Request the service.
    ContentCategoryRemote service = new DfaServices().get(session, ContentCategoryRemote.class);

    // Create content category structure.
    ContentCategory contentCategory = new ContentCategory();
    contentCategory.setId(0);
    contentCategory.setName(contentCategoryName);
    contentCategory.setDescription(contentCategoryDescription);

    // Create content category.
    ContentCategorySaveResult contentCategorySaveResult =
        service.saveContentCategory(contentCategory);

    // Display content category ID.
    System.out.println("Content category with ID \"" + contentCategorySaveResult.getId()
        +  "\" was created.");
  }
}
